package cz.data.common.database;

import cz.data.common.database.datasource.JdbcDataSourceFactory;
import cz.data.common.support.db.DbType;
import cz.data.common.support.db.source.DataSourceRegistry;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PreDestroy;

@Configuration
public class DatabaseAutoConfiguration {

    @PreDestroy
    public void destroy() {
        CacheDataSourceBean.shutdown();
    }

    static {
        DataSourceRegistry.register(new JdbcDataSourceFactory(),
                DbType.MYSQL, DbType.MARIADB, DbType.POSTGRE_SQL,
                DbType.ORACLE, DbType.ORACLE_12C, DbType.SQL_SERVER,
                DbType.SQL_SERVER2008, DbType.VERTICA);
    }
}
